package com.sky.controller.user;

import com.sky.entity.Category;
import com.sky.entity.Setmeal;
import com.sky.entity.SetmealDish;
import com.sky.result.Result;
import com.sky.service.CatgoryService;
import com.sky.service.DishService;
import com.sky.service.SetmealService;
import com.sky.vo.DishListVo;
import com.sky.vo.SetmealVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RequestMapping("/user/setmeal")
@RestController
public class UserSetmealController {
@Autowired
    private SetmealService setmealService;
@GetMapping("/list")
@Cacheable(cacheNames = "setmealCache",key = "#categoryId")
public Result<List<Setmeal>> userSetmealList(Long categoryId){
List<Setmeal> setmeal= setmealService.byCategoryID(categoryId);
    return Result.success(setmeal);

}
@GetMapping("/dish/{id}")

    public Result byid(@PathVariable Long id){

    SetmealVO setmealVO = setmealService.byId(id);
    List<SetmealDish> setmealDishes = setmealVO.getSetmealDishes();
    return Result.success(setmealDishes);
}
}
